<%@ page contentType="text/html; charset=UTF-8" language="java"%>
<%@ page import="com.hzqy.commons.utils.ConstantUtils" %>
<%@ taglib prefix="limits" uri="/WEB-INF/tld/limits.tld"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>组织管理</title>
<link rel="stylesheet" type="text/css"	href="../static/js/themes/defalut.css">
<link rel="stylesheet" type="text/css"	href="../static/js/themes/public.css">
<link rel="stylesheet" type="text/css"	href="../static/js/themes/ddspstyle.css">
<link rel="stylesheet" type="text/css"	href="../static/js/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"	href="../static/js/themes/icon.css">
<link href="../static/css/uploadify.css" rel="stylesheet" type="text/css"/>

<script type="text/javascript" src="../static/js/jquery.min.js"></script>
<script type="text/javascript" src="../static/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../static/js/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="../static/js/index.js"></script>
<script src="../static/js/jquery.uploadify.js" type="text/javascript"></script>
<%
		String para = request.getParameter("f_po_id");
		int f_po_id = 0;
		if(para != null)
			f_po_id = Integer.valueOf(para);
		String []nonceObj=ConstantUtils.getNonceObject();
	%>
<script type="text/javascript">
		var queryParams;
		function EasyuiDatagrid() {
			$("#easyui-datagrid").datagrid({
				url: '../pms/org_select_parentId.do',
				nowrap: true,
				striped: true,
				border: false,
				fit: true,
				rownumbers:true,
				queryParams: getGueryParams(),
				columns: [[
					{field:'f_po_id',title:'组织ID',align:'center',width:50},
					{field:'f_po_name',title:'组织名称',align:'center',width:188},
					{field:'f_po_english',title:'组织英文名',align:'center',width:150},
					{field:'f_po_status',title:'状态',align:'center',width:80,
						formatter:function(value,row,index) {
							var status = "未知";
							if(value==1){
								status="上线";
							} else if(value==2){
								status="无效";
							} else if(value==5){
								status="待处理";
							} else if(value==6){
								status="不通过";
							}
							return status;
						}	
					},
					{field:'f_po_updateAt',title:'修改时间',align:'center',width:150},
					{field:'_parentId',title:'操作',align:'center',width:150,
						formatter:function(value,row,index){
							str ="";
							if(row.f_po_status==5){
								str+= '<a class="easyui-linkbutton l-btn l-btn-plain" iconCls="icon-ok" href="javascript:void(0);" plain="true" onclick="tg(\''+row.f_po_id+'\');" ><span class="l-btn-left"><span class="l-btn-text icon-ok l-btn-icon-left">通过</span></span></a>';
								str+= '<a class="easyui-linkbutton l-btn l-btn-plain" iconCls="icon-ok" href="javascript:void(0);" plain="true" onclick="btg(\''+row.f_po_id+'\');" ><span class="l-btn-left"><span class="l-btn-text icon-remove l-btn-icon-left">不通过</span></span></a>';
							}
					    	return str;
				    	}
					}
				]],
				singleSelect:true,
				pagination:true,
				pageList:[10,20,30,40,50],
				pageSize:10,
				toolbar: '#toolbar',
				onExpandRow: function(index,row){
					
				},
				onSelect: function(rowIndex,rowData) {
					
				},
				onUnselect: function(rowIndex,rowData) {
					
				},
				onCheckAll: function(rowIndex,rowData) {
					
				},
				onUncheckAll: function(rowIndex,rowData) {
				
				},
				onLoadSuccess: function(data) {
					if(data.total==-1) {
						$.messager.defaults={ok:"确定",cancel:"取消"};
						$.messager.confirm('提示', '用户尚未登录,请登录', function(r){
						if (r){
						    window.parent.location.href='/login.do';
						    return false;
						}});
					}
				}
			});
		}
		
		function tg(f_po_id){
			$.messager.confirm('确定通过该组织','确定通过该组织么?',function(r){
				if(r){
					app_ajax('../pms/update_org_status.do?f_po_id='+f_po_id+"&f_po_status=1"+"&&stime=<%=nonceObj[0]%>&sign=<%=nonceObj[1]%>",
					'',
					function(msg){
						if(msg.success) {
							alert("保存成功!");
							if (checkAjaxRequestValidity(msg)) {
								gotoSearch($('#easyui-treegrid'));
							}
						} else {
							alert("保存异常，请联系管理员");
							if($.isFunction(window.showMessager)){
								window.showMessager(msg.resultTitle,msg.result);
							}
						}
						window.location.reload();
					}
					);
				}
			});
		}
		
		function btg(f_po_id){
			$.messager.confirm('确定不通过该组织','确定不通过该组织么?',function(r){
				if(r){
					app_ajax('../pms/update_org_status.do?f_po_id='+f_po_id+'&f_po_status=6'+'&stime=<%=nonceObj[0]%>&sign=<%=nonceObj[1]%>',
					'',
					function(msg){
						if(msg.success) {
							alert("保存成功!");
							if (checkAjaxRequestValidity(msg)) {
								gotoSearch($('#easyui-treegrid'));
							}
						} else {
							alert("保存异常，请联系管理员");
							if($.isFunction(window.showMessager)){
								window.showMessager(msg.resultTitle,msg.result);
							}
						}
						window.location.reload();
					}
					);
				}
			});
		}
		function getGueryParams(){
			return {
				f_po_name:$("#f_po_name").val(),
				f_po_status:$("#f_po_status").val(),
				f_po_parentId:<%=f_po_id%>,
			};
		}
		
		function getGueryParamsAll(){
			return {
				f_po_name:$("#f_po_name").val(),
				f_po_status:$("#f_po_status").val(),
			};
		}
		$(function(){
			new EasyuiDatagrid();
			gotoSearch = function(){
				$("#easyui-datagrid").datagrid('reload',getGueryParams());
			};
			gotoSearchAll = function(){
				$("#easyui-datagrid").datagrid('reload',getGueryParamsAll());
			};
		});
		function onpress(){
			var event=arguments.callee.caller.arguments[0]||window.event;//消除浏览器差异
	   		  	if (event.keyCode == 13){  
	      			gotoSearch($('#easyui-treegrid'));
	    		}
		}
</script>
</head>
<body>
	<input type="hidden" id="sessionId" value="${pageContext.session.id}" />
	<table id="easyui-datagrid" title="组织列表"></table>
	<div id="toolbar" class="easyui_datagrid_toolbar" style="">
		<div class="easyuiSearch">
			<form onsubmit="return false;" method="post">
				<table cellspacing="0" cellpadding="0" width="90%">
					<tr>
						<td align="left" width="8%">组织名称：</td>
						<td align="left" width="15%"><input name="f_po_name" id="f_po_name" style="width: 150px;"  onkeydown="onpress();"/></td>
						<td align="left" width="8%">组织状态：</td>
						<td align="left" width="8%">
							<select id="f_po_status" name="f_po_status">
									<option value="0">请选择</option>
									<option value="1">有效</option>
									<option value="2">审核中</option>
									<option value="4">审核未通过</option>
									<option value="5">待处理</option>
									<option value="6">不通过</option>
							</select>
						</td>
						<td align="left" width="10%">
							<limits:uiAuth url="content_list.do">
								<a href="javascript:void(0);" class="easyui-linkbutton"
									data-options="iconCls:'icon-search', plain:true"
									onclick="gotoSearch($('#easyui-datagrid'))">查询</a>
							</limits:uiAuth>
						</td>
						<td align="left" width="10%">
							<limits:uiAuth url="content_list.do">
								<a href="javascript:void(0);" class="easyui-linkbutton"
									data-options="iconCls:'icon-search', plain:true"
									onclick="gotoSearchAll($('#easyui-datagrid'))">全局查询</a>
							</limits:uiAuth>
						</td>
					</tr>
				</table>
			</form>
		</div>
	</div>
</div>		
</body>
</html>